-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
-- 定义函数来检查并打开 URL
--
--
-- 自动保存zf折叠
vim.api.nvim_create_augroup("AutoSaveFolds", { clear = true })

vim.api.nvim_create_autocmd("BufWinLeave", {
  pattern = "*",
  callback = function()
    local bufname = vim.api.nvim_buf_get_name(0) -- 获取当前缓冲区的文件名
    if bufname ~= "" then -- 如果文件名不为空，执行 mkview
      vim.cmd("mkview")
    end
  end,
})
vim.api.nvim_create_autocmd("BufWinEnter", {
  pattern = "*",
  callback = function()
    vim.cmd("silent! loadview")
  end,
  group = "AutoSaveFolds",
})
